import * as actions from '../actions/public';

const initialState = {
  userName: '', //用户名
  isLogin:'',   //登录状态
};

export default function index(state = initialState, action = {}) {
  switch (action.type) {
    //登录成功后在全局状态中设置用户信息
    case actions.LOGIN_SUC:
      return Object.assign({}, state, {
        userName: action.data.name,
        isLogin: true
      });
      case actions.LOGOUT_SUC:
      return Object.assign({}, state, {
        userName: '',
        isLogin: false
      });
    default:
      return state;
  }
}
